<html>
<head><meta charset="utf-8"><title>Understanding PhantomData and dropchk · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html">Understanding PhantomData and dropchk</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197195321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197195321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197195321">(May 11 2020 at 19:47)</a>:</h4>
<p>Hi, I'm trying to understand the usage of PhantomData to tell dropck that we "own T" I easily see the usage for PhantomData in lifetimes, but not here I read the comment above this: <a href="https://github.com/rust-lang/rust/blob/master/src/libcore/ptr/unique.rs#L45">https://github.com/rust-lang/rust/blob/master/src/libcore/ptr/unique.rs#L45</a>, the link, the nomicon sections about dropchk+PhantomData<br>
and still don't get it.<br>
Any explanations/examples are welcome :)</p>



<a name="197197035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197197035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197197035">(May 11 2020 at 20:01)</a>:</h4>
<p>I believe it's because the dropcheck goes "outside in", if i'm reading the RFC linked to by that comment correctly.</p>



<a name="197202426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197202426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197202426">(May 11 2020 at 20:45)</a>:</h4>
<p>EDIT: I misunderstood the question.</p>



<a name="197202655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197202655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197202655">(May 11 2020 at 20:47)</a>:</h4>
<p>No, it would still compile. That use of <code>PhantomData</code> is purely for dropck, as the comment indicates.</p>



<a name="197202762"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197202762" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197202762">(May 11 2020 at 20:48)</a>:</h4>
<p>Ah, does</p>
<div class="codehilite"><pre><span></span><code>    // NOTE: this marker has no consequences for variance, but is necessary
    // for dropck to understand that we logically own a `T`.
</code></pre></div>


<p>invalidate my claims (i.e. the "no consequence for variance" part).</p>



<a name="197208360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Understanding%20PhantomData%20and%20dropchk/near/197208360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> zeroexcuses <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Understanding.20PhantomData.20and.20dropchk.html#197208360">(May 11 2020 at 21:43)</a>:</h4>
<p>I read <a href="https://doc.rust-lang.org/nomicon/dropck.html">https://doc.rust-lang.org/nomicon/dropck.html</a> a few times. I understand the importance of Generic arguments strictly out living a type. what I don't understand now is -- how does this related to the <code>Unique&lt;T&gt;</code> example above?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>